package logic.weapons.projectileWeapons.artillary;

import com.jme.math.Vector3f;

import logic.weapons.WeaponFire;
import logic.weapons.projectileWeapons.ProjectileWeapon;
import logic.weapons.projectileWeapons.ProjectileWeaponController;

public class ArtillaryWeaponController extends ProjectileWeaponController {
	
	private static final long serialVersionUID = 1L;
	private Vector3f midLoc, midDir;
	
	public ArtillaryWeaponController(ProjectileWeapon weapon) {
		super(weapon);
		
		midLoc = ArtillaryController.getMSHalfLoc(weapon.getShip().getTeam());
		weapon.lookAt(midLoc, Vector3f.UNIT_Y);
		midDir = midLoc.subtract(weapon.getWorldTranslation());
	}
	
	@Override
	public void update(float time) {
		super.update(time);
		
		WeaponFire fire = weapon.fire(midDir);
		if(fire != null) {
			weapon.addProjectile();
			weapon.getIngameState().addNode(fire);
		}
	}
}